<?php
$denyDeleteFunc = create_function('$role', '
$deny = array("guest", "systems");
return in_array($role->getName(), $deny) ? "disabled":"";
');
?>
<form id="dialog" class="hide">
    <table class="none">
      <tr>
        <td align="right">角色名: </td>
        <td><input type="text" name="name" /></td>
      </tr>
      <tr>
        <td align="right">title:</td>
        <td><input type="text" name="title" /></td>
      </tr>
    </table>
    <button type="submit" class="hide"></button>
</form>

<?php if (isset($this->employees)):?>
<form id="assign" class="hide">
<input name="type" type="hidden" value="set">
<input name="id" type="hidden">
<table class="none">
  <tr class="list-head">
    <td width="150">未加入成员</td>
    <td width="70" align="center">操作</td>
    <td width="150">加入成员</td>
  </tr>
  <tr>
    <td><select style="width:100%; height:250px;" multiple="multiple" id="user-out">
    <?php foreach ($this->employees as $r) :?>
    <option value="<?=$r->getEmployeeId()?>"><?=$r->getRealName()?></option>
    <?php endforeach;?>
    </select></td>
    <td align="center"><button onclick="RoleList.userAdd()">添加=&gt;</button><p /><button onclick="RoleList.userRemove()">&lt;=删除</button></td>
    <td><select style="width:100%; height:250px;" multiple="multiple" name="employees[]"  id="user-in"></select></td>
  </tr>
</table>
</form>
<?php endif;?>
<div id="content-bar">
<button onclick="RoleList.data.add();" class="ui-icon-plus"></button>
添加角色</button>
</div>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab-1" id="list">
    <tr>
        <th width="60">ID</th>
        <th width="150">Title</th>
        <th>角色名</th>
        <th width="140">管理</th>
    </tr>
    <tr id="template" class="hide">
        <td name="role_id">#role_id#</td>
        <td name="title">#title#</td>
        <td name="name">#name#</td>
        <td align="center">
            <a class="ig-button" href="/system/resource/list/role_id/#role_id#" title="资源权限分配">
                <span class="ui-icon ui-icon-key"></span>
            </a>
            <button onclick="RoleList.assign('#role_id#', '#name#', this);" title="用户成员" class="ui-icon-person"></button>
            <button onclick="RoleList.data.edit('#role_id#', this);" title="编辑" class="ui-icon-pencil"></button>
            <button onclick="RoleList.data.del('#role_id#', this);" title="删除" class="ui-icon-trash"></button>
        </td>
    </tr>
    <?php foreach ($this->roles as $role):?>
    <tr>
        <td name="role_id"><?=$role->getRoleId()?></td>
        <td name="title"><?=$role->getTitle()?></td>
        <td name="name"><?=$role->getName()?></td>
        <td align="center">
            <a class="ig-button" href="/system/resource/list/role_id/<?=$role->getRoleId()?>" title="资源权限分配">
            <span class="ui-icon ui-icon-key"></span></a>
            <button onclick="RoleList.assign(<?=$role->getRoleId()?>, '<?=$role->getName()?>', this);" title="用户成员" class="ui-icon-person"></button>
            <button <?=$denyDeleteFunc($role)?> onclick="RoleList.data.edit(<?=$role->getRoleId()?>, this);" title="编辑" class="ui-icon-pencil"></button>
            <button <?=$denyDeleteFunc($role)?> onclick="RoleList.data.del(<?=$role->getRoleId()?>, this);" title="删除" class="ui-icon-trash"></button>
        </td>
    </tr>
    <?php endforeach;?>
    <tfoot><tr><td colspan="4">
    <?php echo $this->paginationControl($this->paginator, 'Sliding', 'page.phtml', array ('params' => $this->params ) ); ?>
    </td></tr></tfoot>
</table>
<div class="paginator">

</div>